package com.ams.media;

import java.io.IOException;
import com.ams.io.BufferList;
import com.ams.io.RandomAccessFileReader;

public class MediaSample extends MediaMessage {
    protected boolean keyframe;
    protected long offset;
    protected int size;

    public MediaSample(int mediaType, long timestamp, BufferList data) {
        super(mediaType, timestamp, data);
    }

    public MediaSample(int mediaType, long timestamp, boolean keyframe,
            long offset, int size) {
        super(mediaType, timestamp, null);
        this.keyframe = keyframe;
        this.offset = offset;
        this.size = size;
    }

    public void readData(RandomAccessFileReader reader) throws IOException {
        reader.seek(offset);
        data = new BufferList(reader.read(size));
    }

    public long getOffset() {
        return offset;
    }

    public int getSize() {
        return size;
    }

    public boolean isKeyframe() {
        return keyframe;
    }

}
